import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import java.io.StringWriter;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws JAXBException {
        // 创建记录列表
        Record record1 = new Record(1);
        Record record2 = new Record(2);

        // 创建子元素并将记录添加到子元素
        Child child1 = new Child("Alice", 10, Arrays.asList(record1, record2));
        
        // 创建父元素并将子元素添加到父元素
        Parent parent = new Parent(Arrays.asList(child1));
        
        // 创建JAXB上下文并执行转换
        JAXBContext context = JAXBContext.newInstance(Parent.class);
        Marshaller marshaller = context.createMarshaller();
        
        // 设置输出格式
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        
        // 转换为XML并输出
        StringWriter writer = new StringWriter();
        marshaller.marshal(parent, writer);
        
        System.out.println(writer.toString());
    }
}
